//
//  ChartingTop1CollectionViewCell.m
//  intelligent
//
//  Created by 甘世清 on 2024/3/1.
//

#import "ChartingTop1CollectionViewCell.h"
#import "LookImageView.h"
@implementation ChartingTop1CollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    [self.contentView addSubview:self.bgimage];
    [self.bgimage mas_makeConstraints:^(MASConstraintMaker *make) {
         make.edges.equalTo(self.contentView);
    }];
}
- (void)setModel:(HotModel *)model{
    [super setModel:model];
    [self.bgimage sd_setImageWithURL:SQURLImage(model.url)];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    LookImageView * view = [[LookImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDETH, SCREEN_HEIGHT)];
    [view.bgimage sd_setImageWithURL:SQURLImage(self.model.url)];
    LSTPopView * pop = [LSTPopView initWithCustomView:view
                                             parentView:nil
                                               popStyle:LSTPopStyleFade dismissStyle:LSTDismissStyleFade];
      pop.hemStyle = LSTHemStyleCenter;
    pop.dragStyle = LSTDragStyleAll;
    pop.dragDistance = SCREEN_WIDETH/3.f;
    [pop pop];
    LSTPopViewWK(pop)
       [view setImageBlock:^{
           [wk_pop dismiss];
       }];
      
      [pop setBgClickBlock:^{
          [wk_pop dismiss];
      }];
}
- (UIImageView *)bgimage{
    if (!_bgimage) {
        _bgimage = [[UIImageView alloc]init];
        _bgimage.contentMode = UIViewContentModeScaleAspectFill;
        _bgimage.clipsToBounds = YES;
        _bgimage.backgroundColor = SQColorF4F4F4;
        _bgimage.layer.cornerRadius = 8;
        _bgimage.layer.masksToBounds = YES;
    }
    return _bgimage;
}

@end
